import java.util.Scanner;
import java.util.Arrays;

public class String_1_7_30 {
    public static void main(String[] args) {
        String x, y;
        char[] a = new char[3000];
        char[] b = new char[3000];
        Scanner input = new Scanner(System.in);
        x = input.next();
        y = input.next();
        a = x.toCharArray();
        b = y.toCharArray();
        int len1 = a.length, len2 = b.length;
        int x1 = Math.max(len1, len2);
        int cnt = 0, maxn = 0;
        for (int i = 0; i < len1; i++) {
            for (int j = 0; j < len2; j++) {
                cnt = 0;
                for (int k = 0; k < x1; k++) {
                    if (a[(i + k) % len1] == b[(j + k) % len2]) {
                        cnt++;
                    } else {
                        maxn = Math.max(cnt, maxn);
                        cnt = 0;
                    }
                }
            }
        }
        System.out.print(maxn);
    }
}